﻿<%@ page import="entity.UserStatic" %>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%--<base href=<%=request.getContextPath()+"/jsp/"%>--%>
<%--动态包含无法使用，页面报错，newsService无法使用 <jsp:include page="../common/common.jsp" /> --%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<style type="text/css">
		table{
			margin: 20px;
		}
		.color{
			background: grey;
		}
	</style>
	<script type="text/javascript" src="../js/jquery-1.12.4.min.js"></script>
<title>新闻列表</title>
</head>
<body>
<%
	out.print("当前观看直播人数:"+UserStatic.user);
%>
<script type="text/javascript">
	function add() {
		location.href="/jsp/newsDetailCreateSimple.jsp";
	}
	function del(id) {
		if (confirm("确定要删除吗？")){
			location.href="/newsServlet?action=del&id="+id;
		}else {
			alert("您取消了删除");
		}

	}
</script>
<a href="/jsp/newsZhuXiao.jsp">注销</a>
<!--主体-->
    <div class="main-content-right">
        <!--即时新闻-->
        <div class="main-text-box">
            <div class="main-text-box-tbg">
                <div class="main-text-box-bbg">
                    <form name ="searchForm" id="searchForm" action="" method="">
		 	          <div>
		 				新闻分类：
		 					<select name="categoryId" id="categoryId">
		 						<option value="-1">全部</option>
			        			
			        				<option value='1' >国内</option>
			        			
			        				<option value='2' >国际</option>
			        			
			        				<option value='3' >娱乐</option>
			        			
			        				<option value='4' >军事</option>
			        			
			        				<option value='5' >财经</option>
			        			
			        				<option value='6' >天气</option>
			        			
	        				</select>
		 				新闻标题<input type="text" name="title" id="title" value=''/>
		 					<button type="button" class="page-btn" >GO</button>
		 					<button type="button"  class="page-btn" onclick="add()">增加</button>
		 					<input type="hidden" name="currentPageNo" value="1"/>
		 					<input type="hidden" name="pageSize" value="10"/>
		 					<input type="hidden" name="totalPageCount" value="2"/>
		 	</div>
		 	</form>
			<table id="newsList"  border="1" cellpadding="0" cellspacing="0" class="admin-list" style="width: 500px">
				<thead >
					<tr class="admin-list-head">
						<th>新闻标题</th>
                        <th>作者</th>
                        <th>时间</th>
                        <th>操作</th>
                    </tr>

                </thead>
                <tbody>
				<c:forEach var="news" items="${newsList}" varStatus="indexs">
					<tr <c:if test="${indexs.count%2==0}"> class="color"</c:if>>
					<th><c:out value="${news.title}" escapeXml="true"/></th>
					<th>${news.author}</th>
					<th>
						<fmt:formatDate value="${news.createDate}" pattern="yyyy-MM-dd"/>
					</th>
					<th>
						<a href="/newsServlet?action=get&id=${news.id}">${news.id}编辑</a>
						<a href="javascript:void(0)" onclick="del(${news.id})">删除</a>
					</th>
				</tr>
				</c:forEach>
				</tbody>
            </table>
           <div class="page-bar">
				<span>
					共<span id="total"></span>条记录&nbsp;&nbsp; <span id="pageNo"></span>/<span id="totalPages"></span>页&nbsp;&nbsp;&nbsp;&nbsp;
					<a href="#" id="begin">首页</a>&nbsp;&nbsp;&nbsp;&nbsp;
					<a href="#" id="prev">上一页</a>&nbsp;&nbsp;&nbsp;&nbsp;
					<a href="#" id="next">下一页</a>&nbsp;&nbsp;&nbsp;&nbsp;
					<a href="#" id="end">最后一页</a>
				</span>
		 <span class="page-go-form"><label>跳转至</label>
	     <input type="text" name="inputPage" id="inputPage" class="page-key" />页
	     <button type="button" id="page-btn" class="page-btn" >GO</button>
		</span>
		</div> 
        </div>
       </div>
   </div>
   </div>
</body></html>